using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._GeoAnalyticsDesktopTools._AnalyzePatterns
{
    /// <summary>
    /// <para>Generalized Linear Regression</para>
    /// <para>Performs generalized linear regression 
    /// (GLR) to generate predictions or to model a dependent variable in terms of its relationship to a set of explanatory variables. This tool can be used to fit continuous (OLS), binary (logistic), and count (Poisson) models.</para>
    /// <para>执行广义线性回归
    /// （GLR） 根据因变量与一组解释变量的关系生成预测或建模。此工具可用于拟合连续 （OLS）、二进制 （logistic） 和计数 （Poisson） 模型。</para>
    /// </summary>    
    [DisplayName("Generalized Linear Regression")]
    public class GeneralizedLinearRegression : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public GeneralizedLinearRegression()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_input_features">
        /// <para>Input Features</para>
        /// <para>The layer containing the dependent and independent variables.</para>
        /// <para>包含因变量和自变量的图层。</para>
        /// </param>
        /// <param name="_dependent_variable">
        /// <para>Dependent Variable</para>
        /// <para>The numeric field containing the observed values to be modeled.</para>
        /// <para>包含要建模的观测值的数值字段。</para>
        /// </param>
        /// <param name="_model_type">
        /// <para>Model Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the type of data that will be modeled.</para>
        ///   <bulletList>
        ///     <bullet_item>Continuous (Gaussian)— The Dependent Variable is continuous. The Gaussian model will be used, and the tool will perform ordinary least squares regression. This is the default.</bullet_item><para/>
        ///     <bullet_item>Binary (Logistic)— The Dependent Variable represents presence or absence. This can be either conventional 1s and 0s, or string values mapped to 0 or 1s in the explanatory_variables_to_match parameter. The Logistic regression model will be used.</bullet_item><para/>
        ///     <bullet_item>Count (Poisson)—The Dependent Variable is discrete and represents events, for example, crime counts, disease incidents, or traffic accidents. The Poisson regression model will be used.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定要建模的数据类型。</para>
        ///   <bulletList>
        ///     <bullet_item>连续（高斯）— 因变量是连续的。将使用高斯模型，该工具将执行普通最小二乘回归。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>二进制 （Logistic）— 因变量表示存在或不存在。这可以是常规的 1 和 0，也可以是映射到 explanatory_variables_to_match 参数中的 0 或 1 的字符串值。将使用 Logistic 回归模型。</bullet_item><para/>
        ///     <bullet_item>计数 （Poisson） - 因变量是离散变量，表示事件，例如犯罪计数、疾病事件或交通事故。将使用泊松回归模型。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// </param>
        /// <param name="_explanatory_variables">
        /// <para>Explanatory Variable(s)</para>
        /// <para>A list of fields representing independent explanatory variables in the regression model.</para>
        /// <para>表示回归模型中独立解释变量的字段列表。</para>
        /// </param>
        /// <param name="_output_features">
        /// <para>Output Features</para>
        /// <para>The name of the feature class that will be created containing the dependent variable estimates and residuals.</para>
        /// <para>将创建的包含因变量估计值和残差的要素类的名称。</para>
        /// </param>
        public GeneralizedLinearRegression(object _input_features, object _dependent_variable, _model_type_value _model_type, List<object> _explanatory_variables, object _output_features)
        {
            this._input_features = _input_features;
            this._dependent_variable = _dependent_variable;
            this._model_type = _model_type;
            this._explanatory_variables = _explanatory_variables;
            this._output_features = _output_features;
        }
        public override string ToolboxName => "GeoAnalytics Desktop Tools";

        public override string ToolName => "Generalized Linear Regression";

        public override string CallName => "gapro.GeneralizedLinearRegression";

        public override List<string> AcceptEnvironments => ["extent", "outputCoordinateSystem", "parallelProcessingFactor", "workspace"];

        public override object[] ParameterInfo => [_input_features, _dependent_variable, _model_type.GetGPValue(), _explanatory_variables, _output_features, _input_features_to_predict, _explanatory_variables_to_match, _dependent_variable_mapping, _output_predicted_features, _coefficient_table];

        /// <summary>
        /// <para>Input Features</para>
        /// <para>The layer containing the dependent and independent variables.</para>
        /// <para>包含因变量和自变量的图层。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _input_features { get; set; }


        /// <summary>
        /// <para>Dependent Variable</para>
        /// <para>The numeric field containing the observed values to be modeled.</para>
        /// <para>包含要建模的观测值的数值字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Dependent Variable")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _dependent_variable { get; set; }


        /// <summary>
        /// <para>Model Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the type of data that will be modeled.</para>
        ///   <bulletList>
        ///     <bullet_item>Continuous (Gaussian)— The Dependent Variable is continuous. The Gaussian model will be used, and the tool will perform ordinary least squares regression. This is the default.</bullet_item><para/>
        ///     <bullet_item>Binary (Logistic)— The Dependent Variable represents presence or absence. This can be either conventional 1s and 0s, or string values mapped to 0 or 1s in the explanatory_variables_to_match parameter. The Logistic regression model will be used.</bullet_item><para/>
        ///     <bullet_item>Count (Poisson)—The Dependent Variable is discrete and represents events, for example, crime counts, disease incidents, or traffic accidents. The Poisson regression model will be used.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定要建模的数据类型。</para>
        ///   <bulletList>
        ///     <bullet_item>连续（高斯）— 因变量是连续的。将使用高斯模型，该工具将执行普通最小二乘回归。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>二进制 （Logistic）— 因变量表示存在或不存在。这可以是常规的 1 和 0，也可以是映射到 explanatory_variables_to_match 参数中的 0 或 1 的字符串值。将使用 Logistic 回归模型。</bullet_item><para/>
        ///     <bullet_item>计数 （Poisson） - 因变量是离散变量，表示事件，例如犯罪计数、疾病事件或交通事故。将使用泊松回归模型。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Model Type")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public _model_type_value _model_type { get; set; }

        public enum _model_type_value
        {
            /// <summary>
            /// <para>Binary (Logistic)</para>
            /// <para>Binary (Logistic)— The Dependent Variable represents presence or absence. This can be either conventional 1s and 0s, or string values mapped to 0 or 1s in the explanatory_variables_to_match parameter. The Logistic regression model will be used.</para>
            /// <para>二进制 （Logistic）— 因变量表示存在或不存在。这可以是常规的 1 和 0，也可以是映射到 explanatory_variables_to_match 参数中的 0 或 1 的字符串值。将使用 Logistic 回归模型。</para>
            /// </summary>
            [Description("Binary (Logistic)")]
            [GPEnumValue("BINARY")]
            _BINARY,

            /// <summary>
            /// <para>Continuous (Gaussian)</para>
            /// <para>Continuous (Gaussian)— The Dependent Variable is continuous. The Gaussian model will be used, and the tool will perform ordinary least squares regression. This is the default.</para>
            /// <para>连续（高斯）— 因变量是连续的。将使用高斯模型，该工具将执行普通最小二乘回归。这是默认设置。</para>
            /// </summary>
            [Description("Continuous (Gaussian)")]
            [GPEnumValue("CONTINUOUS")]
            _CONTINUOUS,

            /// <summary>
            /// <para>Count (Poisson)</para>
            /// <para>Count (Poisson)—The Dependent Variable is discrete and represents events, for example, crime counts, disease incidents, or traffic accidents. The Poisson regression model will be used.</para>
            /// <para>计数 （Poisson） - 因变量是离散变量，表示事件，例如犯罪计数、疾病事件或交通事故。将使用泊松回归模型。</para>
            /// </summary>
            [Description("Count (Poisson)")]
            [GPEnumValue("COUNT")]
            _COUNT,

        }

        /// <summary>
        /// <para>Explanatory Variable(s)</para>
        /// <para>A list of fields representing independent explanatory variables in the regression model.</para>
        /// <para>表示回归模型中独立解释变量的字段列表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Explanatory Variable(s)")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public List<object> _explanatory_variables { get; set; }


        /// <summary>
        /// <para>Output Features</para>
        /// <para>The name of the feature class that will be created containing the dependent variable estimates and residuals.</para>
        /// <para>将创建的包含因变量估计值和残差的要素类的名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _output_features { get; set; }


        /// <summary>
        /// <para>Input Prediction Features</para>
        /// <para>A layer containing features representing locations where estimates will be computed. Each feature in this dataset should contain values for all the explanatory variables specified. The dependent variable for these features will be estimated using the model calibrated for the input layer data.</para>
        /// <para>包含表示将计算估计值的位置的要素的图层。此数据集中的每个要素都应包含所有指定解释变量的值。这些要素的因变量将使用为输入层数据校准的模型进行估计。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Prediction Features")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _input_features_to_predict { get; set; } = null;


        /// <summary>
        /// <para>Match Explanatory Variables</para>
        /// <para>Matches the explanatory variables in the Input Prediction Features parameter to corresponding explanatory variables from the Input Features parameter.</para>
        /// <para>将输入预测要素参数中的解释变量与输入要素参数中的相应解释变量进行匹配。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Match Explanatory Variables")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _explanatory_variables_to_match { get; set; } = null;


        /// <summary>
        /// <para>Map Dependent Variables</para>
        /// <para>Two strings representing the values used to map to 0 (absence) and 1 (presence) for binary regression. By default, 0 and 1 will be used. For example, to predict an arrest with field values of Arrest and No Arrest, you would enter No Arrest for False Value (0) and Arrest for True Value (1).</para>
        /// <para>两个字符串表示用于映射到 0（不存在）和 1（存在）的二元回归的值。默认情况下，将使用 0 和 1。例如，要预测字段值为 Arrest 和 No Arrest 的逮捕，请输入 No Arrest for False Value （0） 和 Arrest for True Value （1）。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Map Dependent Variables")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _dependent_variable_mapping { get; set; } = null;


        /// <summary>
        /// <para>Output Predicted Features</para>
        /// <para>The output feature class with the dependent variable estimates for each Input Prediction Features value.</para>
        /// <para>具有每个输入预测要素值的因变量估计值的输出要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Predicted Features")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_predicted_features { get; set; } = null;


        /// <summary>
        /// <para>Table of Coefficients Features</para>
        /// <para>The output feature class with the dependent variable estimates for each Input Prediction Features value.</para>
        /// <para>具有每个输入预测要素值的因变量估计值的输出要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Table of Coefficients Features")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _coefficient_table { get; set; } = null;


        public GeneralizedLinearRegression SetEnv(object extent = null, object outputCoordinateSystem = null, object parallelProcessingFactor = null, object workspace = null)
        {
            base.SetEnv(extent: extent, outputCoordinateSystem: outputCoordinateSystem, parallelProcessingFactor: parallelProcessingFactor, workspace: workspace);
            return this;
        }

    }

}